﻿using System;
using System.Collections.Generic;
using System.Text;

namespace GeoFly
{
    //林冠截留类
public class CanopyStorage  
{
    public CanopyStorage()
    {
        m_dPcpCoeff = 0.046;
        m_dCd = 0.7;
        m_dPcp = 0;
        m_dLAI = 0;
    }
    /// <summary>
    /// 设置栅格上林冠截留参数
    /// </summary>
    /// <param name="dLai"></param>
    /// <param name="dpcp"></param>
    /// <param name="dCd"></param>
    /// <param name="pcpcoeff"></param>
	public void SetGridValue(double dLai,double dpcp,double dCd,double pcpcoeff)
    {
        m_dPcpCoeff = pcpcoeff;
        m_dCd = dCd;
        m_dPcp = dpcp;
        m_dLAI = dLai;
        if (m_dLAI <= 0)
            m_dLAI = 0.001;
        if (m_dCd <= 0)
            m_dCd = 0.001;
    }
	/// <summary>
	/// 计算冠层截留
	/// </summary>
	/// <returns></returns>
    public double CanopyStore()
    {
        double dret = 0;
        double dCrownIC = CrownIC();
        double dPcpCoeff = PcpInterCCoeff();
        dret = (dCrownIC * (1 - Math.Exp(-1 * dPcpCoeff * m_dPcp / dCrownIC))) * 1.1;
        if (dret > m_dPcp)
            dret = m_dPcp;
        return dret;
    }
	/// <summary>
    /// 林冠截留能力计算
	/// </summary>
	/// <returns></returns>
    public double CrownIC()
    {
        double dret = 0;
	dret = 0.935 * 0.498 * m_dLAI - 0.00575 * m_dLAI * m_dLAI;
	dret = dret * m_dCd;
	return dret;
    }
    /// <summary>
    /// 降雨截留系数计算
    /// </summary>
    /// <returns></returns>
	public double PcpInterCCoeff()
    {
        return m_dPcpCoeff * m_dLAI;
    }
	
    public double m_dPcpCoeff,m_dCd,m_dPcp,m_dLAI;				
};
}
